package com.gzsxy.NIO.zerocopy;

import java.io.DataInputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

/**
 * @author xiaolong
 * @version 1.0
 * @description: 使用传统的 IO 方法传递一个大文件
 * @date 2022/5/9 19:58
 */
public class OldIOServer {


    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(7001);

        while (true) {
            //监听连接
            Socket socket = serverSocket.accept();
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());

            byte[] bytes = new byte[4096];
            while (true){
                int readCount = dataInputStream.read(bytes, 0, bytes.length);
                if (-1 == readCount){
                    break;
                }
            }

        }
    }

}


